
<?php
	require_once("connect_sql.php");
	
	$day = $_GET['day'];
	$endDate = $_GET['endDate'];
	$startDate = date('Y-m-d', strtotime(-$day.' day'));
	$startDate = date('Y-m-d', strtotime($endDate.-$day.' day'));
	//echo 'startDate:'.$startDate.'---endDate:'.$endDate;
	$sql = 'select * from log where date between "'.$startDate.'" and "'.$endDate.'" order by id desc';
	$result = mysql_query($sql);
	if(!$result) {
		echo mysql_error();
		return;
	}
	$date = '';
	echo '<table>';
	while($row = mysql_fetch_array($result)) {
		if($date != $row['date']) {
			$date = $row['date'];
			echo '<tr class="dateCap"><td colspan="4">'.date('Y年m月d日', strtotime($date)).'</td></tr>';
		}
		echo '<tr>';
		echo '<td><span>['.$row['id'].']</td>';
		echo '<td class="nickname">'.$row['nickname'].'</td>';
		echo '<td class="action">'.$row['action'].'</td>';
		echo '<td>'.$row['content'].'</td>';
	}
	echo '</table>';
?>